#include "edge_laplacian_of_gauss.h"

#include "blur_gaussian.h"

EdgeLaplaceOfGauss::EdgeLaplaceOfGauss(PNM* img) :
    Convolution(img)
{
}

EdgeLaplaceOfGauss::EdgeLaplaceOfGauss(PNM* img, ImageViewer* iv) :
    Convolution(img, iv)
{
}

math::matrix<double> EdgeLaplaceOfGauss::getMask(int, Mode)
{
	int radius = size / 2;

    math::matrix<double> mask(size, size);

	for (int i = -radius; i <= radius; i++)
		for (int j = -radius; j <= radius; j++)
			mask(i + radius, j + radius) = getLoG(i, j, sigma);

    return mask;
}

void EdgeLaplaceOfGauss::setParameters(int _size, double _sigma)
{
	size = _size;
	sigma = _sigma;
}

double EdgeLaplaceOfGauss::getLoG(int x, int y, double s)
{
	return ((pow(x,2)+pow(y,2))/pow(s,2) - 2/pow(s,2))* BlurGaussian::getGauss(x, y, s);
}

int EdgeLaplaceOfGauss::getSize()
{
    return size;
}
